//
// Color.cpp for  in /home/herpec_j/Dropbox/Projets/raytracer-2016/Sources/Maths/
//
// Made by Jonathan
// Login   <ledey_l@epitech.net>
//
// Started on  Sun Sep 22 17:03:20 2013 Jonathan
// Last update Sun Sep 22 17:24:10 2013 Jonathan
//

#include		"Maths/Color.hpp"

namespace		Maths
{
  Color::Color(void) : mR(0.0), mG(0.0), mB(0.0)
  {
    return;
  }

  Color::Color(long double rValue) : mR(rValue), mG(rValue), mB(rValue)
  {
    return;
  }

  Color::Color(long double rR, long double rG, long double rB) : mR(rR), mG(rG), mB(rB)
  {
    return;
  }

  Color::Color(Color const &rOther) : mR(rOther.mR), mG(rOther.mG), mB(rOther.mB)
  {
    return;
  }

  Color			&Color::operator=(Color const &rOther)
  {
    if (this != &rOther)
      {
	mR = rOther.mR;
	mG = rOther.mG;
	mB = rOther.mB;
      }
    return (*this);
  }

  bool			Color::operator==(Color const &rOther) const
  {
    return (mR == rOther.mR && mG == rOther.mG && mB == rOther.mB);
  }

  bool			Color::operator!=(Color const &rOther) const
  {
    return (mR != rOther.mR || mG != rOther.mG || mB != rOther.mB);
  }

  Color			Color::operator+(Color const &rOther) const
  {
    return (Color(mR + rOther.mR, mG + rOther.mG, mB + rOther.mB));
  }

  Color			Color::operator*(long double rValue) const
  {
    return (Color(mR * rValue, mG * rValue, mB * rValue));
  }

  Color			Color::operator*(Color const &rOther) const
  {
    return (Color(mR * rOther.mR, mG * rOther.mG, mB * rOther.mB));
  }

  Color			Color::operator/(long double rValue) const
  {
    return (Color(mR / rValue, mG / rValue, mB / rValue));
  }

  Color			&Color::operator+=(Color const &rOther)
  {
    mR += rOther.mR;
    mG += rOther.mG;
    mB += rOther.mB;
    return (*this);
  }

  Color			&Color::operator*=(long double rValue)
  {
    mR *= rValue;
    mG *= rValue;
    mB *= rValue;
    return (*this);
  }

  Color			&Color::operator/=(long double rValue)
  {
    mR /= rValue;
    mG /= rValue;
    mB /= rValue;
    return (*this);
  }

  long double		Color::operator[](int rIndex) const
  {
    switch (rIndex)
      {
      case 0:
	return (mR);
	break;
      case 1:
	return (mG);
	break;
      case 2:
	return (mB);
	break;
      default:
	return (0.0);
	break;
      }
  }

  Color			Color::PowC(long double rValue) const
  {
    return (Color(pow(mR, rValue), pow(mG, rValue), pow(mB, rValue)));
  }

  long double		Color::Average(void) const
  {
    return (0.333333333333 * (mR + mG + mB));
  }

  Color::~Color(void)
  {
    return;
  }

  Color			operator*(long double rValue, Color const &rColor)
  {
    return (Color(rValue * rColor[0], rValue * rColor[1], rValue * rColor[2]));
  }
};
